import { getAdminList } from "@/services/account"
import { IAdmin } from './account'
import { Effect, ImmerReducer } from 'umi'
export interface IAdminState {
  adminList: IAdmin[]
}
export interface IAdminModel {
  namespace: 'account',
  state: IAdminState,
  effects: {
    getAdminListReq: Effect
  },
  reducers: {
    changeAdminList: ImmerReducer<IAdminState>
  }
}
const adminModel: IAdminModel = {
  namespace: 'account',
  state: {
    adminList: []
  },
  effects: {
    * getAdminListReq ({ payload }, { call, put }) {
      const res = yield call(getAdminList, payload)
      yield put({
        type: 'changeAdminList',
        payload: res.data.data
      })
    }
  },
  reducers: {
    changeAdminList (state, action) {
      state.adminList = action.payload
    }
  }
}

export default adminModel
